$(function() {
    var serverIP = 'http://11.16.127.79:80';
    var dpsyIP = 'http://11.16.127.79:8082';
    var logOutIP = 'http://11.16.125.16:10004';
    var insertHtml = '<div class="xxjg">' +
        '<div class="triangle_border_up" ></div>' +
        '</div>' +
        '<div class="header1">' +
        '<div class="image-left"></div>' +
        '<div class="headerContentText" style="float: left;padding: 11px 0px 14px 60px;">' +
        '<a class="a_index" target="_self"><div class="headerItem"><img src="/ditu/images/home.png" width="15" height="15" /> </div><span>首页</span></a>' +
        // '<a class="a_spyy"><div class="headerItem"><img src="..//ditu/images/shuju.png" width="15" height="15"></div><span>视频应用</span></a>' +
        '<a class="a_scfw"><div class="headerItem"><img src="/ditu/images/pingtaiguanli.png" width="15" height="15"></div><span>搜车服务</span></a>' +
        // '<a class="a_rxdsj"><div class="headerItem"><img src="..//ditu/images/pingtaiapicanshu3.png" width="15" height="15"></div><span>人像大数据</span></a>' +
        '<a class="a_jzffw"><div class="headerItem"><img src="/ditu/images/pingtaiapicanshu3.png" width="15" height="15"></div><span>技战法服务</span></a>' +
        '<a class="a_ztcfw"><div class="headerItem"><img src="/ditu/images/applications.png" width="15" height="15"></div><span>重点车辆治理</span></a>' +
        // '<a class="a_cgaj"><div class="headerItem"><img src="..//ditu/images/anjiandangan.png" width="15" height="15" /></div><span>城管案件</span> </a>' +
        // '<a class="a_jtwfsj"><div class="headerItem"><img src="..//ditu/images/applications.png" width="15" height="15" /></div><span>交通违法事件</span></a>' +
        //  '<a class="a_zhszyy"><div class="headerItem"><img src="..//ditu/images/applications.png" width="15" height="15" /></div><span>综合实战应用</span></a>' +
        '</div>' +
        '<div class="logout-right"><img width="20" height="20" src="/ditu/images/logout.png" /></div>' +
        '<div class="header-home"><img src="/ditu/images/th-list-copy.png" width="23" height="23" /></div>' +
        '<div class="nav-panel  pre-scrollable">' +
        // '<h3 class="panel-title"><i class="iconfont icon-shujuyanpan"></i><span>视频应用</span> </h3>' +
        // '<div class="menu-list"><ul class="row">' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/fr/#/video/surveillanceVideo" class="btn btn-block button-red" role="button">态势分析</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/fr/#/video/history" class="btn btn-block button-orange" role="button">录像回放</a></li>' +
        // '<li class="col-md-3 con-xs-4"> <a href="'+serverIP+'/fr/#/video/policeRoutes" class="btn btn-block button-blue" role="button">警卫路线</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/fr/#/systemOperation/deviceManage" class="btn btn-block button-green" role="button">设备管理</a></li>' +
        // '<li class="col-md-3 con-xs-4"> <a href="'+serverIP+'/fr/#/systemOperation/deviceLabelManage" class="btn btn-block button-purple" role="button">标签管理</a> </li>' +
        // '<li class="col-md-3 con-xs-4"> <a href="'+serverIP+'/fr/#/systemAdmin/patrolConf" class="btn btn-block button-red" role="button">巡逻管理</a></li>' +
        // '<li class="col-md-3 con-xs-4"> <a href="'+serverIP+'/fr/#/systemAdmin/configurationScene" class="btn btn-block button-orange" role="button">场景管理</a></li>' +
        // '</ul></div>' +
        '<h3 class="panel-title"><i class="iconfont icon-shujuyanpan"></i><span>搜车服务</span> </h3>' +
        '<div class="menu-list"><ul class="row">' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/motorvehicle/motorvehicle.html" class="btn btn-block button-red" role="button">图神搜车</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/danger/danger.html" class="btn btn-block button-orange" role="button">危险品车</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/person/uncar2.html" class="btn btn-block button-blue" role="button">非机动车</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/motorvehicle/searchCarWithPic.html" class="btn btn-block button-green" role="button">以图搜车</a> </li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/motorvehicle/mhtzFindCar.html" class="btn btn-block button-purple" role="button">模糊特征搜车</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/vehicleControl/vehicleControl.html" class="btn btn-block button-red" role="button">布控告警</a></li>' +
        '</ul></div>' +
        '<h3 class="panel-title"><i class="iconfont icon-shujuyanpan"></i><span>技战法服务</span> </h3>' +
        '<div class="menu-list"><ul class="row">' +
        '<li class="col-md-3 con-xs-4"><a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/motorvehicle/motorvehicle.html" class="btn btn-block button-red" role="button">车辆轨迹</a></li>' +
        '<li class="col-md-3 con-xs-4"><a target="_blank" href="' + serverIP + '/vias_app/views/vias/technicaltactics/vehiclefollow/vehiclefollow.html" class="btn btn-block button-orange" role="button">伴随车辆</a></li>' +
        '<li class="col-md-3 con-xs-4"><a target="_blank" href="' + serverIP + '/vias_app/views/vias/technicaltactics/vehiclezonewander/vehicleZoneWander.html" class="btn btn-block button-blue" role="button">区域徘徊</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/technicaltactics/frequentnightout/frequentNightOut.html" class="btn btn-block button-green" role="button">频繁夜出</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/topic/nocturnal/nocturnal.html" class="btn btn-block button-purple" role="button">昼伏夜出</a> </li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/topic/abnormality/abnormality.html" class="btn btn-block button-red" role="button">异常徘徊</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/technicaltactics/scopeactivity/scopeActivity.html" class="btn btn-block button-orange" role="button">活动范围</a></li>' +
        '<li class="col-md-3 con-xs-4"><a target="_blank" href="' + serverIP + '/vias_app/views/vias/technicaltactics/endpoint/endpoint.html" class="btn btn-block button-blue" role="button">落脚点分析</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/topic/areatractcrash/areaTractCrash.html" class="btn btn-block button-green" role="button">区域碰撞</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/technicaltactics/fakedeck/fakeDeck.html" class="btn btn-block button-purple" role="button">假套牌</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/topic/inventory/inventory.html" class="btn btn-block button-red" role="button">保有量</a></li>' +
        '</ul></div>' +
        '<h3 class="panel-title"><i class="iconfont icon-shujuyanpan"></i><span>重点车辆治理</span> </h3>' +
        '<div class="menu-list"><ul class="row">' +
        '<li class="col-md-3 con-xs-4"><a target="_blank" href="' + serverIP + '/ditu/index.html" class="btn btn-block button-red" role="button">源头管控</a></li>' +
        '<li class="col-md-3 con-xs-4"><a target="_blank" href="' + serverIP + '/vias_app/views/vias/snapshot/vehicleTrajectory/vehicleTrajectory.html" class="btn btn-block button-orange" role="button">车路协同</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="" class="btn btn-block button-blue" role="button">集约利用</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + '/vias_app/views/vias/urbanManagementLawEnforcement/chgzhf/cgzfmh.html" class="btn btn-block button-green" role="button">城管执法</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="' + serverIP + 'vias_app/views/vias/snapshot/jiaotong/shishiSP.html" class="btn btn-block button-purple" role="button">交通执法</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="" class="btn btn-block button-red" role="button">区城管委</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="" class="btn btn-block button-orange" role="button">区住建委</a></li>' +
        '<li class="col-md-3 con-xs-4"> <a target="_blank" href="" class="btn btn-block button-blue" role="button">区环保局</a></li>' +
        '</ul></div>' +
        // '<h3 class="panel-title"><i class="iconfont icon-shujuyanpan"></i><span>人像大数据</span></h3>' +
        // '<div class="menu-list"> <ul class="row">' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/vias_app/views/vias/snapshot/face/face.html" class="btn btn-block button-red" role="button">人脸搜索</a> </li>' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/vias_app/views/vias/snapshot/face/facetrajectory.html" class="btn btn-block button-orange" role="button">智能搜脸</a> </li>' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/vias_app/views/vias/snapshot/face/oneToNIdentification.html" class="btn btn-block button-blue" role="button">静态比对</a> </li>' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/vias_app/views/vias/snapshot/face/faceFrequency.html" class="btn btn-block button-green" role="button">频次分析</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/vias_app/views/vias/snapshot/person/person.html" class="btn btn-block button-purple" role="button">人员检索</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="'+serverIP+'/vias_app/views/vias/snapshot/person/personAndFace.html" class="btn btn-block button-red" role="button">人员轨迹</a></li>' +
        // '</ul></div>' +
        // '<h3 class="panel-title"><i class="iconfont "></i><span>城管案件</span></h3>' +
        // '<div class="menu-list cgaj"><ul class="row">' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-red" role="button">违法处理查询</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-orange" role="button">视频研判</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-blue" role="button">地图研判</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-green" role="button">数据统计</a></li>' +
        // '</ul></div>' +
        // '<h3 class="panel-title"><i class="iconfont "></i><span>交通违法事件</span></h3>' +
        // '<div class="menu-list jtwfaj"><ul class="row">' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-red" role="button">实时任务监控</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-orange" role="button">违法事件抓怕</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-blue" role="button">场景识别区域</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-green" role="button">场景行为配置</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-purple" role="button">设备能管理</a></li>' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-red" role="button">统计分析</a></li>' +
        // '</ul></div>' +
        // '<h3 class="panel-title"><i class="iconfont icon-shujuyanpan"></i><span>综合实战应用</span> </h3>' +
        // '<div class="menu-list"><ul class="row">' +
        // '<li class="col-md-3 con-xs-4"><a href="" class="btn btn-block button-red" role="button">一车一档</a></li>' +
        // '</ul></div>' +
        '</div></div>';

    $(".headerCommonMenu").html(insertHtml);
    // const spyyMenuList = ["态势分析", "录像回放", "警卫路线", "设备管理", "标签管理", "巡逻管理", "场景配置"];
    // const rxdsjMenuList = ["人脸搜索", "智能搜脸", "静态比对", "频次分析", "人员检索", "人员轨迹"];
    // const ztcMenuList = ["重点车辆检索", "按车型查询", "按设备查询", "重点车辆报告", "区域统计分析"];
    // const cgMenuList = ["违法处理查询", "视频研判", "地图研判", "数据统计"];
    // const jtMenuList = ["实时任务监控", "违法事件抓拍", "场景识别区域", "场景行为配置", "设备管理", "统计分析"];
    const scfwMenuList = ["图神搜车", "危险品车", "非机动车", "以图搜车", "模糊特征搜车", "布控告警"];
    const jzffwMenuList = ["车辆轨迹", "伴随车辆", "区域徘徊", "频繁夜出", "昼伏夜出", "异常徘徊", "活动范围", "落脚点分析", "区域碰撞", "假套牌", "保有量"];
    const ztcfwMenuList = ["源头管控", "车路协同", "集约利用", "城管执法", "交通执法", "区城管委", "区住建委", "区环保局"];
    const cgMenuList = ["违法处理查询", "视频研判", "地图研判", "数据统计"];
    const zhszMenuList = ["一车一档"];
    var theRequest = new Object();

    function GetRequest() {
        var url = location.search; //获取url中"?"符后的字串
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    GetRequest();
    if (theRequest["subMenu"] === "scfw") {
        $($(".a_scfw").children("span")).css("color", "#7dc304");
    } else if (theRequest["subMenu"] === "jzffw") {
        $($(".a_jzffw").children("span")).css("color", "#7dc304");
    } else if (theRequest["subMenu"] === "cg") {
        $($(".a_cgaj").children("span")).css("color", "#7dc304");
    } else if (theRequest["subMenu"] === "zhsz") {
        $($(".a_zhszyy").children("span")).css("color", "#7dc304");
    }
    var token = theRequest["token"];
    var linkClassName = theRequest["className"];
    var user = theRequest["user"];
    var screeType = theRequest["screeType"];
    $(".menu-list li").click(function() {
        if (!$($(this).children("a")[0]).attr("href") || $($(this).children("a")[0]).attr("href") === '') {
            // $('.xxjg').css("display","block");
            $(".xxjg").show().delay(3000).hide(300);
            return false;
        } else {
            /*当前标签下的a标签*/
            var obj = $(this).children("a");
            /*获取第一个a标签，进行跳转*/
            // window.open($(obj[0]).attr("href") + token);
            var hrefUrl = $(obj[0]).attr("href");
            let hrefText = $(obj[0]).text();
            let itemindex = $(this).index();
            let subMenu1 = "";
            if (scfwMenuList[itemindex] === hrefText) {
                subMenu1 = "scfw";
                $(obj[0]).attr("href", hrefUrl + "?token=" + token + "&subMenu=" + subMenu1 + "&user=" + user + "&screeType=" + screeType);
            } else if (jzffwMenuList[itemindex] === hrefText) {
                subMenu1 = "jzffw";
                $(obj[0]).attr("href", hrefUrl + "?token=" + token + "&subMenu=" + subMenu1 + "&user=" + user + "&screeType=" + screeType);
            } else if (ztcfwMenuList[itemindex] === hrefText) {
                subMenu1 = "ztcfw";
                $(obj[0]).attr("href", hrefUrl + "?token=" + token + "&subMenu=" + subMenu1 + "&user=" + user + "&screeType=" + screeType);
            } else if (cgMenuList[itemindex] === hrefText) {
                subMenu1 = "cg";
                $(obj[0]).attr("href", hrefUrl + "?token=" + token + "&subMenu=" + subMenu1 + "&user=" + user + "&screeType=" + screeType);
            } else if (zhszMenuList[itemindex] === hrefText) {
                subMenu1 = "zhsz";
                $(obj[0]).attr("href", hrefUrl + "?token=" + token + "&subMenu=" + subMenu1 + "&user=" + user + "&screeType=" + screeType);
            } else {
                $(".xxjg").show().delay(3000).hide(300);
                return false;
            }
        }
    });
    $(".logout-right").click(function() {
        $.ajax({
            type: "get", //向后台请求的方式，有post，get两种方法
            url: logOutIP + "/ajaxLogout", //url填写的是请求的路径
            cache: false, //缓存是否打开
            // data: {//请求的数据，
            // },
            headers: {
                "authorization": token
            },
            dataType: 'json', //请求的数据类型
            success: function(data) { //请求的返回成功的方法
                if (data) {
                    console.log("注销成功。");
                    window.localStorage.clear(); //清空所有的存储数据
                    window.sessionStorage.clear();
                    window.location.href = serverIP + "/portal/index.html";
                } else {
                    console.log("注销失败，原因：" + data.msg);
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) { //请求的失败的返回的方法
                console.log("注销失败，请稍后再次尝试！");
            }
        });
    });
    $(".headerContentText a").click(function() {
        if ($(this).index() === 0) {
            window.location.href = dpsyIP + "/portal/dpsy2/index2?token=" + token + "&user=" + user + "&screeType=" + screeType;
        } else {
            var linkClassName = $(this).attr("class")
            window.open(serverIP + "/home/index.html?token=" + token + "&user=" + user + "&screeType=" + screeType + "&className=" + linkClassName);
        }
    });

});